package com.darker.secking.controller;

import com.darker.secking.service.IUserService;
import com.darker.secking.vo.LoginVo;
import com.darker.secking.vo.RespBean;
import com.darker.secking.vo.RespBeanEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

@Controller
@Slf4j
@RequestMapping("/login")
public class LoginController {

    @Autowired
    IUserService userService;


    @RequestMapping("/toLogin")
    public String toLogin(){
        return "login";
    }


    @PostMapping(value = "/doLogin",produces = "application/json;charset=UTF-8")
    @ResponseBody
    public RespBean doLogin( LoginVo loginVo, HttpServletRequest request,
                            HttpServletResponse response){
        return  userService.doLogin(loginVo,request,response);
    }
}
